/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hibernate.entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ariel
 */
@Entity
@Table(name = "productos")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Productos.findAll", query = "SELECT p FROM Productos p"),
    @NamedQuery(name = "Productos.findByCodStock", query = "SELECT p FROM Productos p WHERE p.codStock = :codStock"),
    @NamedQuery(name = "Productos.findByNombre", query = "SELECT p FROM Productos p WHERE p.nombre = :nombre"),
    @NamedQuery(name = "Productos.findByStock", query = "SELECT p FROM Productos p WHERE p.stock = :stock"),
    @NamedQuery(name = "Productos.findByPrecio", query = "SELECT p FROM Productos p WHERE p.precio = :precio")})
public class Productos implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "cod_stock")
    private String codStock;
    @Column(name = "nombre")
    private String nombre;
    @Lob
    @Column(name = "descripcion")
    private String descripcion;
    @Column(name = "stock")
    private Short stock;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "precio")
    private double precio;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codStock")
    private List<DetallePedCli> detallePedCliList;
    @JoinColumn(name = "cod_prov", referencedColumnName = "cod_prov")
    @ManyToOne
    private Proveedores codProv;
    @OneToMany(mappedBy = "codStock")
    private List<DetallePedProv> detallePedProvList;

    public Productos() {
    }

    public Productos(String codStock) {
        this.codStock = codStock;
    }

    public String getCodStock() {
        return codStock;
    }

    public void setCodStock(String codStock) {
        this.codStock = codStock;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public Short getStock() {
        return stock;
    }

    public void setStock(Short stock) {
        this.stock = stock;
    }

    public double getPrecio() {
        return precio;
    }

    public void setPrecio(double precio) {
        this.precio = precio;
    }

    @XmlTransient
    public List<DetallePedCli> getDetallePedCliList() {
        return detallePedCliList;
    }

    public void setDetallePedCliList(List<DetallePedCli> detallePedCliList) {
        this.detallePedCliList = detallePedCliList;
    }

    public Proveedores getCodProv() {
        return codProv;
    }

    public void setCodProv(Proveedores codProv) {
        this.codProv = codProv;
    }

    @XmlTransient
    public List<DetallePedProv> getDetallePedProvList() {
        return detallePedProvList;
    }

    public void setDetallePedProvList(List<DetallePedProv> detallePedProvList) {
        this.detallePedProvList = detallePedProvList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codStock != null ? codStock.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Productos)) {
            return false;
        }
        Productos other = (Productos) object;
        if ((this.codStock == null && other.codStock != null) || (this.codStock != null && !this.codStock.equals(other.codStock))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "hibernate.entidades.Productos[ codStock=" + codStock + " ]";
    }
    
}
